package com.woniuxy.woniumall.service;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.woniumall.mapper.BookMapper;
import com.woniuxy.woniumall.vo.BookVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookService {
    @Autowired
    BookMapper bookMapper ;


    @Cacheable(value = "book",key = "#root.targetClass+#root.methodName+#root.args[0]+#root.args[1]+#root.args[2]+#root.args[3]")
    public PageInfo<BookVo> findBookByPage(String name, Integer cataId, Integer now, Integer size) {
        PageHelper.startPage(now,size);
        List<BookVo> lists = bookMapper.selectBookByNameAndCataId(name,cataId);
        return new PageInfo<>(lists);
    }

    public BookVo findBookByKey(int id) {
        return bookMapper.selectBookByKey(id);
    }
}
